package com.jiangyg.mall.coupon.service;

import com.jiangyg.mall.core.support.restful.Pagination;
import com.jiangyg.mall.coupon.dao.HomeSubjectDao;
import com.jiangyg.mall.coupon.dto.HomeSubjectDTO;
import com.jiangyg.mall.coupon.entity.HomeSubject;
import com.jiangyg.mall.coupon.vo.HomeSubjectVO;
import com.jiangyg.mall.db.mybatis.BaseServiceImpl;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class HomeSubjectServiceImpl extends BaseServiceImpl<HomeSubjectDao, HomeSubject> implements HomeSubjectService {

    @Autowired
    public HomeSubjectServiceImpl(HomeSubjectDao homeSubjectDao) {
        super(homeSubjectDao);
    }

    @Override
    @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
    public Pagination<HomeSubjectVO> selectPagination(Pagination<HomeSubjectVO> pagination) throws Exception {
        return this.executeSelectPagination(pagination, HomeSubjectVO.class);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean saveOrUpdate(HomeSubjectDTO dto) throws Exception {
        return this.executeSaveOrUpdate(dto) > 0;
    }

    @Override
    @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
    public HomeSubjectVO selectById(Long homeSubjectId) throws Exception {
        return this.executeSelectById(homeSubjectId, HomeSubjectVO.class);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean delete(List<Long> homeSubjectIds) {
        return this.baseMapper.deleteBatchIds(homeSubjectIds) > 0;
    }

}
